package rpg.role
{
	import rpg.Utils.Log;
	import rpg.Utils.Val;
	import rpg.animation.AvatarDescription;
	import rpg.avatar.AvatarComponent;
	import rpg.data.HeroData;
	import rpg.data.Spell;
	import rpg.data.SpriteStat;
	import rpg.factory.GameFactory;
	import rpg.manager.GameManager;

	public class Hero extends StateObject
	{
		public var data : HeroData;
		public var spellList : Array;
		public var shortCutIocs : Array;

		public function Hero(id : String)
		{
			super(id);

		}

		override public function update(elapsedTime : uint) : void
		{
			if(!isActive)
				return;
			super.update(elapsedTime);
			if(data && data.currHP <= 0 && state != Val.DEAD)
				changeState(Val.DEAD);
		}

		public function changeAvatar(avatarDes : AvatarDescription , parts : Array) : void
		{
			var avatarComponent : AvatarComponent = getComponent(AvatarComponent);
			avatarComponent.changeAvatar(avatarDes , parts);
			if(avatarComponent.avatar)
			{
				width = avatarComponent.avatar.width;
				height = avatarComponent.avatar.height;
			}
		}

		override public function destroy() : void
		{
			super.destroy();
			data = null;
			spellList = null;
		}
	}
}